﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;

namespace Gueei.Gallery.Core.Filters
{
	public class RotateImageFilter:ImageFilter
	{
		public enum RotateAngle
		{
			Rotate90, Rotate270, Rotate180
		}

		private const double ConvertGradient = 2*Math.PI/360;

		private RotateAngle _angle;

		public RotateImageFilter(RotateAngle angle)
		{
			_angle = angle;
		}

		public override Image ApplyFilter(Image image)
		{
			var angle = _angle;
			if (image == null)
				throw new ArgumentNullException("image");

			switch(_angle)
			{
				case RotateAngle.Rotate90:
					image.RotateFlip(RotateFlipType.Rotate90FlipNone);
					break;
				case RotateAngle.Rotate270:
					image.RotateFlip(RotateFlipType.Rotate270FlipNone);
					break;
				case RotateAngle.Rotate180:
					image.RotateFlip(RotateFlipType.Rotate180FlipNone);
					break;
			}

			return image;
		}
	}
}
